package customview.com.imageselectordemo.GalleryFinall;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.ListView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

import cn.finalteam.galleryfinal.CoreConfig;
import cn.finalteam.galleryfinal.FunctionConfig;
import cn.finalteam.galleryfinal.GalleryFinal;
import cn.finalteam.galleryfinal.ThemeConfig;
import cn.finalteam.galleryfinal.model.PhotoInfo;
import customview.com.imageselectordemo.R;

public class Ac_GalleryFianll extends AppCompatActivity {

    private static final int REQUEST_CODE_GALLERY = 102;
    ChoosePhotoListAdapter mChoosePhotoListAdapter;
    List mPhotoList;
   ListView listView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ac__gallery_fianll);
       listView = (ListView) findViewById(R.id.listview);
        mChoosePhotoListAdapter=new ChoosePhotoListAdapter(this,new ArrayList<PhotoInfo>());
        listView.setAdapter(mChoosePhotoListAdapter);

    }


    public void test(View view) {
        switch (view.getId()) {
            case R.id.start:
                ThemeConfig defaultTheme = GalleryFinalConfig.getDefaultTheme(this);
                FunctionConfig defaultFunctionConfig = GalleryFinalConfig.getDefaultFunctionConfig().build();

                CoreConfig defaultCoreConfig = GalleryFinalConfig.getDefaultCoreConfig(this, defaultTheme, defaultFunctionConfig);
                GalleryFinal.init(defaultCoreConfig);
                GalleryFinal.openGalleryMuti(REQUEST_CODE_GALLERY, 9, mOnHanlderResultCallback);
                break;


        }

    }


    //处理结果

    private GalleryFinal.OnHanlderResultCallback mOnHanlderResultCallback = new GalleryFinal.OnHanlderResultCallback() {
        @Override
        public void onHanlderSuccess(int reqeustCode, List<PhotoInfo> resultList)
        {
            if (resultList != null)
            {
                for (PhotoInfo s:resultList)
                {
                    Log.d("路径", "onHanlderSuccess: 地址"+s.getPhotoPath());
                }
                mChoosePhotoListAdapter.setdate(resultList);
            }
        }

        @Override
        public void onHanlderFailure(int requestCode, String errorMsg)
        {
            Toast.makeText(Ac_GalleryFianll.this, errorMsg, Toast.LENGTH_SHORT).show();
        }
    };


}
